﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using MSWMDMLib;
using FireZone.NativeWMDMInteface;
using System.Runtime.InteropServices;

namespace FireZone
{
    internal class IWMDMStorageEqualityComparer<T>: IEqualityComparer<T> where T: IWMDMStorage
    {
        private static IEqualityComparer<T> _default = new IWMDMStorageEqualityComparer<T>();
        public static IEqualityComparer<T> Default 
        {
            get
            {
                return _default;
            }
        }

        #region IEqualityComparer<T> Members

        public bool Equals(T x, T y)
        {
            if (x.Equals(y)) return true;
            return x.GetStorageMetadataByName(WMDM_DATATYPE_DESC.g_wszWMDMPersistentUniqueID).Equals(y.GetStorageMetadataByName(WMDM_DATATYPE_DESC.g_wszWMDMPersistentUniqueID));
        }

        public int GetHashCode(T obj)
        {
            return 0;
            //throw new NotFiniteNumberException();//
            //return obj.GetStorageMetadataByName(WMDM_DATATYPE_DESC.g_wszWMDMPersistentUniqueID).GetHashCode();
        }

        #endregion
    }
}
